<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="se" uri="http://zc.security/acl"%>
<c:set var="p" value="${param}"></c:set>
<div class="easyui-layout" style="width:100%;height:98%;" fit="true">
    <div data-options="region:'center',title:'',split:true" style="height:98%;">
<form id="productDetailForm" method="post" >
	<input type="hidden" value="" name="productId" />
	<table class="detailTable">
		<tr>
			<td class="detailTable-name">商品编号：</td>
			<td>
				<input type="text" name="productCode" id="d_productCode" data-options="required:true" missingmessage="请输入商品编号">
			</td>
			<td class="detailTable-name">商品显示名称：</td>
			<td>
				<input type="text" name="chsName"  class="easyui-validatebox" data-options="required:true" missingmessage="请输入商品在站点的显示名称：如红色  两只装  爆款  xxxx产品">
			</td>
			<td class="detailTable-name">商品名称：</td>
			<td>
				<input type="text" name="productName"   class="easyui-validatebox" data-options="required:true" missingmessage="请输入商品的包装名称">
			</td>
		</tr>
		<tr>
			<td class="detailTable-name">英文名：</td>
			<td>
				<input type="text" name="engName"   class="easyui-validatebox" data-options="validType:'english'" >
			</td>
			<td class="detailTable-name">拼音码：</td>
			<td>
				<input type="text" name="spell"  class="easyui-validatebox" data-options="required:true,validType:'english'" >
			</td>
			<td class="detailTable-name">商品条码：</td>
			<td>
			<input type="text" name="barcode"   class="easyui-validatebox" >
			</td>
		</tr>
		<tr>
			<td class="detailTable-name">规格：</td>
			<td>
			<input type="text" name="productSpec"  class="easyui-validatebox" data-options="required:true">
			</td>
			<td class="detailTable-name">包装单位：</td>
			<td>
			<input type="text" name="packingUnit"  class="easyui-validatebox" data-options="required:true">
			</td>
			<td class="detailTable-name">批准文号：</td>
			<td>
			<input type="text" name="authorizeNumber"  class="easyui-validatebox" data-options="required:true">
			</td>
		</tr>
			<tr>
			<td class="detailTable-name">大包装数量：</td>
			<td>
			<input type="text" name="packingAmount"  class="easyui-validatebox" >
			</td>
			<td class="detailTable-name">中包装数量：</td>
			<td>
			<input type="text" name="minPackingNumber"  class="easyui-validatebox" >
			</td>
			<td class="detailTable-name">单次购买最小值：</td>
			<td>
			<input type="text" name="minBuy" value="1"  class="easyui-validatebox" data-options="required:true">
			</td>
		</tr>
		<tr>
			<td class="detailTable-name">厂家：</td>
			<td colspan="5">
				生产厂家：
				<input type="text" name="producingName"   class="easyui-validatebox" style="width: 250px;">
				<br/><br/>
				生产产地：
				<input type="text" name="producingArea"    class="easyui-validatebox"  >
				
			</td>
		</tr>
		<tr >
		<td class="detailTable-name">控制销售选择<a href="###" id="showKongxiao" style="color: blue;font-weight: 700;">说明</a>：</td>
		   <td colspan="5">
				<input type="radio" name="isControlSale" value="1" onclick="chooseControlSale('show')">控制销售
				<input type="radio" name="isControlSale" value="0" checked="checked" onclick="chooseControlSale('hide')">不控制销售
		   </td>
		</tr>
		<tr>
		   <td class="detailTable-name">商品价格(<a href="javascript:viewPriceGuiZe();" style="color: blue;font-weight: bold;">价格规则</a>)：</td>
		   <td colspan="5" id="inputId">
		   	门店价：<input type="text" name="shopPrice"    class="easyui-numberbox"  precision="2"  data-options="prefix:'￥'"  >
			现金价：<input type="text" name="cashPrice"    class="easyui-numberbox" precision="2"  data-options="prefix:'￥'"  >
			欠款价：<input type="text" name="arrearsPrice"  class="easyui-numberbox" precision="2"  data-options="prefix:'￥'" >
			<br/>  
			<br/> 
			中包价：<input type="text" name="middlePackPrice"  class="easyui-numberbox" precision="2"  data-options="prefix:'￥'"  >
			整件价：<input type="text" name="fullSalePrice"  class="easyui-numberbox" precision="2"  data-options="prefix:'￥'" >
		   	<br/>  
			<br/>    
		        会员价：<input type="text" name="salePrice" id="d_salePrice"  class="easyui-numberbox" data-options="prefix:'￥',required:true" missingmessage="请输入默认销售价" precision="2"  data-options="prefix:'￥'">
		        零售价：<input type="text" name="retailPrice"    class="easyui-numberbox" data-options="prefix:'￥',required:true" missingmessage="请输入建议零售价" precision="2"  data-options="prefix:'￥'">
		        <a href="javascript:setDefaultPrice();">采用销售价快捷键</a>
            <br/>
            <br/>
               终端价：<input type="text" name="tenSalePrice"  class="easyui-numberbox" precision="2"  data-options="prefix:'￥'" >
               连锁价：<input type="text" name="chnSalePrice"  class="easyui-numberbox" precision="2"  data-options="prefix:'￥'" >
               调拨价：<input type="text" name="trfSalePrice"  class="easyui-numberbox" precision="2"  data-options="prefix:'￥'" >
		   </td>
		</tr>
		<tr id="kongxiaoTr">
		   <td class="detailTable-name">控销价：</td>
		   <td colspan="5">
			控销价： <input type="text" name="controlSalePrice"  class="easyui-numberbox" precision="2"  data-options="prefix:'￥'">
			
		   </td>
		</tr>
		<tr>
			<td class="detailTable-name">分类|品牌：</td>
			<td colspan="5">
			分类：
			<input class="easyui-combotree" id="productTypeCode"   name="productTypeCode" data-options="url:'<c:url value="/product/showEmBproductTypeList.do"/>?viewType=comboTree',method:'post'" style="width: 250px;"  missingmessage="请选择商品的唯一分类">
			<br/> <br/>
			品牌：
			<input type="text" name="brand" id="d_brand" readonly="readonly" class="easyui-validatebox" style="width: 250px;" missingmessage="请选择供应商">
			<input type="hidden" name="brandId" id="d_brandId" >
				<a href="#" onclick="chooseBrand()" class="easyui-linkbutton" data-options="iconCls:'icon-add'">选择</a>
			</td>
		</tr>
		<tr>
			<td class="detailTable-name">效期：</td>
			<td>
				<input name="validMonth" id="validMonth" class="easyui-validatebox" style="width:80px;" >
				 
			</td>
			<td class="detailTable-name">存储条件：</td>
			<td  >
			<input type="text" name="storeCondition" id="storeCondition"   class="easyui-validatebox"  >
			</td>
			<td class="detailTable-name">剂型：</td>
			<td>
			<input type="text" name="medicamentName" id="medicamentName"   class="easyui-validatebox"  >
				
			</td>
		</tr>
		<tr>
			<td class="detailTable-name">医保编号：</td>
			<td>
				<input type="text" name="medicalInsuranceCode"  class="easyui-validatebox" >
			</td>
			<td class="detailTable-name">GMP：</td>
			<td >
				<input type="radio" value="1">已认证 <input type="radio" value="0">未认证
				
				GMP认证号：<input type="text" name="gmpCode"  class="easyui-validatebox" >
			</td>
			<td class="detailTable-name">最小单位体积：</td>
			<td >
				<input type="text" name="unitVol"  class="easyui-validatebox" >
			</td>
		</tr>
		<tr>
			<td class="detailTable-name">排序值：</td>
			<td>
				<input class="easyui-numberspinner" name="sortOrder"   style="width: 70px;">
			</td>
			<td class="detailTable-name">是否新品：</td>
			<td >
				<select name="isNew" >
					<option value="0">默认</option>
					<option value="1">新品</option>
				</select>
			</td>
			<td class="detailTable-name">销售状态：</td>
			<td >
				<select name="isSale" >
					<option value="1">上架</option>
					<option value="0">下架</option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="detailTable-name">展示设置：</td>
			<td colspan="5">
				<input type="checkbox" value="1" name="isIndex">首页显示
				<input type="checkbox" value="1" name="isTop">置顶显示
				<input type="checkbox" value="1" name="isScroll">滚动显示
				<input type="checkbox" value="1" name="isCommend">推荐显示
			</td>
		</tr>
		<tr>
			<td class="detailTable-name">用途：</td>
			<td colspan="5">
				<textarea rows="2" cols="100" name="purpose"></textarea>	
			</td>
		</tr>
		<%
	        String onViewFlag = request.getParameter("onViewFlag");
	        onViewFlag=onViewFlag==null?"":onViewFlag;
	        if(onViewFlag.equals("")){
	        %>
          <tr>
			<td align="center" colspan="6">
				<se:hasPermissions actCode="SUBMIT">
					<input type="button" onclick="submitForm()" class="button" value="提交" >
					<input type="button" onclick="pms.resetForm('productDetailForm')" class="button" value="重置" >
				</se:hasPermissions>
				
			</td>
		</tr>
            <%} %>
		
	</table>
</form>	
</div>
</div>	 
<script type="text/javascript">
$(function(){
	var productCode = "<c:out value="${p.productCode}" />";
	if(productCode==""){
		//load  failture
		//parent.alertError("错误的商品编码  无法加载商品详情");
		//parent.$("#w_product_save_add").dialog('close');
	}else{
		var param = {"productCode":"<c:out value="${p.productCode}" />"}
		$.pmsAjax({
			url : '<c:url value="/product/searchAllProductDetail.do"/>',
			data : param,
			success : function(data) {
				if(data.code==200){
					$('#productDetailForm').form('load', data.data.productDetail);

					if(data.data.productDetail.isControlSale==1){
						chooseControlSale('show');
					}else{
						chooseControlSale('hide');
					}
				}
			}
		});
	}
	$('#showKongxiao').click(function(){
		layer.tips('去控销设置里 设置客户和价格进行对应。', this, {
		    style: ['background-color:#78BA32; color:#fff', '#78BA32'],
		    maxWidth:185,
		    time: 3,
		    closeBtn:[0, true]
		});
	});
	
});


function submitForm(){
	
	$('#productDetailForm').form('submit', {
	    url:'<c:url value="/product/saveOrUpdateEmBProduct.do"/>',
	    onSubmit: function(param){
	    	if(!$("#productDetailForm").form('validate')){
	    		return false;
	    	}
	    },
	    success:function(data){
		    var ret = eval("("+data+")")
	     	if(ret.code=="200"){
	     		parent.alertShow("保存成功");
	     		parent.productsTable.refresh();
	     		parent.$("#w_product_save_add").dialog('close');
		    }else{
		    	alertError(ret.result);
			}
	    }
	});
}

function chooseProvider(){
	$.pmsDialog({
		id:"w_chooseProvider",
		title:'供货商选择',
		method:'post',
		isIf:'true',
		href:'<c:url value="/views/jsp/customer/provider/provider_list_forchoose_s.jsp"/>',
		width:900,
	});
}
//选择供应商
function getProvider(providerName,providerCode){
	$("#d_providerCode").val(providerCode);
	$("#d_providerName").val(providerName);
	$("#w_chooseProvider").dialog('close');
}
//筛选品牌
function chooseBrand(){
	$.pmsDialog({
		id:"w_chooseBrand",
		title:'品牌选择',
		method:'post',
		isIf:'true',
		href:'<c:url value="/views/jsp/brand/brand_list_forchoose_s.jsp"/>',
		width:900,
	});
}
function getBrand(brandChsName,brandId){
	$("#d_brandId").val(brandId);
	$("#d_brand").val(brandChsName);
	$("#w_chooseBrand").dialog('close');
}
//查看价格规则
function viewPriceGuiZe(){
	$.pmsDialog({
		id:"viewPriceGuiZe",
		title:'价格规则',
		method:'post',
		href:'<c:url value="/views/jsp/product/product_view_price.jsp"/>',
		width:300,
		height:250
	});
}
//控制  控销价的 显示和隐藏
function chooseControlSale(v){
	if(v=="show"){
		$("#kongxiaoTr").show();
	}
	if(v=="hide"){
		$("#kongxiaoTr").hide();
	}
	
}
//销售价设置快捷键
function setDefaultPrice(){
	var defaultPrice = $("#d_salePrice").val();
	if(defaultPrice==""){
		alertWarning("请输入销售价");
		$("#d_salePrice").focus();
		return;
	}
	$("#inputId").find("input").each(function(i){
		if(i<14){
			$(this).val(defaultPrice);
		}
	});
}
 
</script>
